import Vue from 'vue'
import App from './App.vue'
import router from './router'
import qs from "qs"

//导入日期操作js
import moment from "moment";
moment.locale("zh-cn");
Vue.prototype.moment = moment;
// 时间全局过滤器
Vue.filter('dateFormat', function (date) {
    return moment(date).format('MM月DD日HH时mm分ss秒')
});

// 导入ele组件库
import ElementUI from 'element-ui'
// 导入ele组件相关样式
import 'element-ui/lib/theme-chalk/index.css'
// 配置ele插件,将其安装到Vue上
Vue.use(ElementUI);

// 引入axios
import axios from 'axios'

//axios.defaults.headers.get['Content-Type']='text/plain'
//基础路径指向微服务网关
axios.defaults.baseURL="http://localhost:9000";
//允许带cookie
axios.defaults.withCredentials=true;
//配置axios拦截请求，添加token头信息
axios.interceptors.request.use(
    config => {
      let accesstoken = localStorage.getItem("access-token");
      // let freshtoken = localStorage.getItem("refresh-token");
      console.log("拦截请求access-token--->" + accesstoken);
      // console.log("拦截请求fresh-token--->" + freshtoken);
      if (accesstoken) {
        //把localStorage的token放在Authorization里
        config.headers.Authorization = accesstoken;
        // config.headers.RefreshToken = freshtoken;
      }
      return config;
    },
    function(err) {
      console.log("失败信息" + err);
    }
);
// 配置axios到Vue
Vue.prototype.axios = axios;
Vue.prototype.qs = qs;

Vue.config.productionTip = false

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
